package IU;

import java.util.Date;

import javax.swing.JLabel;

public class ContageThread extends Thread{
	
	 private JLabel lab;  
	 private Date dateEvent;  
	  
	    public ContageThread(JLabel lab, Date dateEvent) { 
	      this.lab = lab;  
	      this.dateEvent = dateEvent;  
	      start();  
	    }
	    
	    @SuppressWarnings("deprecation")
		public void run() {  
	     	while (true) {  
	          try { sleep(100); } catch (InterruptedException e) {}  
	          Date dateAtua = new Date();  
	          Date dateRest = new Date(dateEvent.getTime() - dateAtua.getTime() + 900);  
	          int minsRest = dateRest.getMinutes();  
	          int seguRest = dateRest.getSeconds();  
	          String contagem = ( "Tempo: " +minsRest +":" + seguRest );  
	          lab.setText(contagem);  
	        }  
	    }
}
